Nc-program conversion device

ABSTRACT

An NC-program conversion device includes an OCR processing unit that recognizes a character string from an input image; a first storage unit that stores one alphabetic letter and the number of digits of a number subsequent to the alphabetic letter, in an associated manner; a second storage unit that stores a program code that is composed of a combination of one alphabetic letter and a two-character number and an effective character that is composed of one alphabetic letter subsequent to the program code, in an associated manner; and a character-string segmenting unit that refers to the first storage unit and the second storage unit, to segment each line of the character string, which is recognized by the OCR processing unit, as program codes stored in the first storage unit in an associated manner.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is based on and claims priority to Japanese PatentApplication No. 2017-130355, filed on Jul. 3, 2017, the entire contentsof which are incorporated herein by reference.

FIELD OF THE INVENTION

The present invention relates to an NC-program conversion device.

BACKGROUND OF THE INVENTION

In the related art, there is a known character recognition device thatreads an image of an application form and that applies OCR (opticalcharacter reader) processing to the read image to recognize characters,thus making description-data entry work efficient (for example, seeJapanese Unexamined Patent Application, Publication No. 2003-108918).

In this character recognition device, characters that tend to bemistaken are registered in advance, and a character that is incorrectlyrecognized as a result of character recognition is replaced with themost likely character among the registered characters.

SYMMARY OF THE INVENTION

The present invention provides the following solutions.

According to one aspect, the present invention provides an NC-programconversion device including: an OCR processing unit that recognizes acharacter string from an input image; a first storage unit that storesone alphabetic letter and the number of digits of a number subsequent tothe alphabetic letter, in an associated manner; a second storage unitthat stores a program code that is composed of a combination of onealphabetic letter and a two-character number and an effective characterthat is composed of one alphabetic letter subsequent to the programcode, in an associated manner; and a character-string segmenting unitthat refers to the first storage unit and the second storage unit, tosegment each line of the character string, which is recognized by theOCR processing unit, as program codes that are each composed of onealphabetic letter and a number corresponding to the number of digitsstored in the first storage unit in an associated manner.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram showing an NC-program conversion deviceaccording to one embodiment of the present invention.

FIG. 2 is a view showing an example numerical-form format stored in astorage unit that is provided in the NC-program conversion device shownin FIG. 1.

FIG. 3 is a view showing an example code-form format stored in thestorage unit, which is provided in the NC-program conversion deviceshown in FIG. 1.

FIG. 4 is a view showing an example numeral-letter conversion liststored in the storage unit, which is provided in the NC-programconversion device shown in FIG. 1.

FIG. 5 is a flowchart for explaining the operation of the NC-programconversion device shown in FIG. 1.

FIG. 6 is a view showing (a) an example of an input handwrittendocument, (b) an example of a result obtained after OCR processing isapplied to the handwritten document shown in (a), and (c) an example ofan NC program generated by the NC-program conversion device of thisembodiment.

FIG. 7 is a view showing (a) another example of an input handwrittendocument, (b) another example of a result obtained after OCR processingis applied to the handwritten document shown in (a), and (c) anotherexample of an NC program generated by the NC-program conversion deviceof this embodiment.

BRIEF DESCRIPTION OF EMBODIMENT(S) OF THE INVENTION

An NC-program conversion device 1 according to one embodiment of thepresent invention will be described below with reference to thedrawings.

As shown in FIG. 1, the NC-program conversion device 1 of thisembodiment is provided with: an image acquisition unit 2 that captureshandwritten characters, a printed document, or a document sent byfacsimile, thus acquiring an image thereof; an OCR processing unit 3that recognizes character strings from the image acquired by the imageacquisition unit 2; a storage unit 4 that stores a numerical-form format(first storage unit), a code-form format (second storage unit), and anumeral-letter conversion list (third storage unit); and acharacter-string segmenting unit 5 that converts the character stringrecognized by the OCR processing unit 3 on the basis of the formats andthe list stored in the storage unit 4.

As shown in FIG. 2, in the numerical-form format, one alphabetic letterand the number of digits of a number subsequent to the alphabetic letterare associated with each other, and a plurality of such combinations arestored.

As shown in FIG. 3, in the code-form format, program codes that are eachcomposed of a combination of one alphabetic letter and a two-characternumber are each stored in association with at least one effectivecharacter that is composed of one alphabetic letter subsequent to theprogram code.

As shown in FIG. 4, the numeral-letter conversion list stores numbersand alphabetic letters that tend to be mistaken for these numbers, in anassociated manner.

The character-string segmenting unit 5 searches for any of thealphabetic letters stored in the numerical-form format, from thebeginning of each line of a character string that is obtained from animage by the OCR processing unit 3, and reads, from the numerical-formformat, the number of digits of a number subsequent to the foundalphabetic letter.

Then, it is determined whether the read alphabetic letter and apredetermined number of digits of a number subsequent to this alphabeticletter exist in the code-form format. If they exist, this combination ofthe alphabetic letter and the number is segmented as a program code. Atthe same time, it is determined whether a character subsequent to theprogram code is an effective character that is stored in the code-formformat in an associated manner. If the character is any effectivecharacter, it is determined that a number subsequent to the effectivecharacter is a number that has the number of digits stored in thenumerical-form format in an associated manner, they are segmented as aprogram code that is composed of the effective character and the number,and the same processing is performed on a subsequent character.

Then, in this way, all character strings converted by the OCR processingunit 3 are segmented in a set of a plurality of program codes, therebymaking it possible to generate an NC program that is input to an NCcontroller and that can put a machine, such as a machine tool, intooperation.

The operation of the thus-configured NC-program conversion device 1 ofthis embodiment will be described below.

In order to generate an NC program from a document printed on paper, byusing the NC-program conversion device 1 of this embodiment, as shown inFIG. 5, the image acquisition unit 2 acquires an image of the document(Step S1), and the OCR processing unit 3 recognizes the image togenerate character strings (Step S2).

Next, a character, e.g., “%”, indicating the start and the end of the NCprogram is assigned to positions flanking the generated characterstrings, thus changing the character strings into an NC-program form(Step S3).

In this state, program codes that function as the NC program aregenerated from the recognized character strings subsequent to “%”.

Specifically, the character-string segmenting unit 5 first determineswhether the leading character of a character string in the first line isan alphabetic letter (Step S4). If the leading character thereof is analphabetic letter, the character-string segmenting unit 5 refers to thenumerical-form format stored in the storage unit 4 (Step S5), extracts,from the character string subsequent to this alphabetic letter, a numbercorresponding to the number of digits stored in association with thisalphabetic letter (Step S6), and segments them as a program code (StepS7).

For example, in a case in which an image of a handwritten document, suchas that shown in FIG. 6(a), is acquired, when the OCR processing unit 3recognizes character strings, as shown in FIG. 6(b), it is determinedwhether the first character “G” is an alphabetic letter (Step S4). Since“G” is an alphabetic letter, the numerical-form format is referred to(Step S5), the number of digits “2” for a number subsequent to “G” isread (Step S6), two characters “43” subsequent to “G” in the characterstring shown in FIG. 6(b) are recognized as a number, and a program code“G43” is segmented (Step S7).

Next, it is determined whether a subsequent character exists (Step S8).If a subsequent character exists, the process steps from Step S4 arerepeated.

In the above-described example, since a character string “250.H01”subsequent to “G43” exists, the process steps from Step S4 are repeated.

In this case, in Step S4, it is determined that the leading character“2” is not an alphabetic letter. Because a program code that is composedof only numbers or symbols does not exist in an NC program, the processflow advances to Step S9, and it is determined whether this character“2” is a number.

Since “2” is a number, the numeral-letter conversion list, which isstored in the storage unit 4, is referred to (Step S10), and “Z”, whichis a candidate stored in association with “2”, is read (Step S11).

Next, the code-form format, which is stored in the storage unit 4, isreferred to (Step S12), and it is determined whether “Z” read in StepS11 is appropriate (Step S13). Whether “Z” is appropriate is determineddepending on whether it is an effective character that is stored inassociation with the program code in the code-form format.

In the above-described example, because the alphabetic letter “Z” is aneffective character in the program code “G43”, it is determined that “Z”is appropriate, and the number “2” is replaced with the alphabeticletter “Z” (Step S14). Then, the numerical-form format is again referredto (Step S5), and the number of digits of a number subsequent to thereplaced “Z” is read (Step S6). Because a three-digit or four-digitnumerical form after a decimal point is associated with “Z”, athree-digit or four-digit number including a decimal point “. (period)”is read from a number subsequent to “Z”; however, “0 (zero)” after thedecimal point can be omitted.

In the above-described example, because the character subsequent to “.”is “H”, it is determined that every “0” subsequent to “.” is omitted,and “50.” is read as a number subsequent to “Z”. Specifically, “Z50.” issegmented as a program code (Step S7).

In a case in which it is determined, in Step S4, that the leadingcharacter is not an alphabetic letter, and in which it is determined, inStep S9, that the leading character is not a number, for example, if theleading character is “0”, because a plurality of candidates are storedin association with “0” in the numeral-letter conversion list, it isdetermined, in Step S13, whether candidate 1 is appropriate. If it isdetermined that the candidate 1 is not appropriate, it is determinedwhether there is another candidate (Step S15). If there is anothercandidate, the process steps from Step S10 are repeated.

In the above-described example, when “H01” at the end of the first lineis segmented as a program code, because a subsequent character does notexist in this line (Step S8), it is determined whether there is asubsequent line (Step S16). If there is a subsequent line, the processsteps from Step S4 are repeated.

Specifically, in the above-described example, “51000” in the second lineis replaced with a program code “S1000”, “2-10.” in the third line isreplaced with “Z-10.”, “150.” in the fourth line is replaced with“I50.”, and “G2820” in the fifth line is replaced with “G28Z0”.

Then, when segmentation of program codes has finished for the characterstrings in all lines, the processing ends.

Furthermore, if it is determined, in Step S9, that the leading characteris not a number, and if it is determined, in Step S15, that there is noother candidate, while an appropriate candidate is not found in StepS13, that character is changed to a comment sentence (Step S17). Thechange of a character to a comment sentence is performed by surroundingthe character with “( ) (brackets)”. Then, after the character ischanged to the comment sentence, the process steps from Step S8 arerepeated.

For example, when an image shown in FIG. 7(a) is subjected to OCRprocessing, thereby recognizing character strings shown in FIG. 7(b),because it is determined, in Step S4, that “.” at the end of the firstline and at the end of the second line is not an alphabetic letter, andit is also determined, in Step S9, that “.” is not a number, “.” issurrounded with 0 in Step S17, thereby obtaining comment sentences shownin FIG. 7(c).

Although segmented parts of the program codes are separated by spacesfor clarification in FIG. 6(c) and FIG. 7(c), no space is required inpractice. Furthermore, in FIG. 6(c), alphabetic letters that tend to bemistaken for numbers, stored in the numeral-letter conversion list areindicated as bold characters.

In this way, according to the NC-program conversion device 1 of thisembodiment, an NC program that can function in an NC controller can begenerated from character strings obtained by recognizing an image ofhandwritten or printed characters. Specifically, if the handwritten orprinted characters are simply converted into most probable characters,there are cases in which they are converted into character strings thatdo not function as an NC program, and characters or symbols that areoriginally unnecessary are converted; however, according to theNC-program conversion device 1 of this embodiment, there is an advantagein that it is possible to generate an executable NC program and toexecute the NC program to check for the presence or absence of a failuretherein.

In particular, a character that is originally unnecessary is recorded inthe form of a comment sentence, which does not interfere with thefunction of the NC program, thereby making it possible to generate theNC program without overlooking an original failure.

Furthermore, in particular, in a machine tool that often uses adifferent NC-program format for each machine, checking of the machine inwhich a failure occurs in the NC program is not easy because it isnecessary to have a good knowledge of the machine, so that there is acase in which a machine maker is hired to check the failure. In thiscase, output of data serving as electronic information is oftenrestricted in view of preventing information leakage, so that there arecases in which the machine maker is asked to check an NC programrecorded on printed matter or a handwritten paper medium.

According to the NC-program conversion device 1 of this embodiment, itis possible not only to simply convert an NC program provided in theform of a paper medium or the like into electronic information but alsoto generate electronic information that functions as an executable NCprogram. Accordingly, there is an advantage in that failure checks canbe immediately executed by the machine maker.

Note that, in this embodiment, for example, when an alphabetic letter“0” indicating a program number is recognized as the leading character,a four-digit character subsequent thereto can be judged as a “number”.For example, when a character string recognized from an image is“Oooo1”, it is also possible to convert “o (lower-case character)” into“0 (zero)” on the basis of the numeral-letter conversion list, thusgenerating a program code “O0001”.

Furthermore, in the same way, when an alphabetic letter “O” isrecognized as the leading character, and a character string subsequentthereto is not a four-digit number, e.g., it is “1”, it is also possibleto add three “0 (zeros)” between “O” and “1”, thus generating a programcode “O0001”.

Furthermore, because some program codes, such as a G-code, function aspreceding modal instruction, even if a G-code does not exist in the sameline, and a recognized leading character is an effective characterstring premised on a G-code etc., it is possible to use the recognizedleading character as an effective character for the G-code existing inthe previous line to generate a program code.

From the above-described embodiments and modifications thereof, thefollowing aspects of the invention are derived.

According to one aspect, the present invention provides an NC-programconversion device including: an OCR processing unit that recognizes acharacter string from an input image; a first storage unit that storesone alphabetic letter and the number of digits of a number subsequent tothe alphabetic letter, in an associated manner; a second storage unitthat stores a program code that is composed of a combination of onealphabetic letter and a two-character number and an effective characterthat is composed of one alphabetic letter subsequent to the programcode, in an associated manner; and a character-string segmenting unitthat refers to the first storage unit and the second storage unit, tosegment each line of the character string, which is recognized by theOCR processing unit, as program codes that are each composed of onealphabetic letter and a number corresponding to the number of digitsstored in the first storage unit in an associated manner.

According to this aspect, when the OCR processing unit converts an inputimage into character strings, the character-string segmenting unitrefers to the first storage unit and the second storage unit andsegments each line of character strings into program codes that are eachcomposed of one alphabetic letter and a number corresponding to thenumber of digits stored in the first storage unit in an associatedmanner. In an NC program, because a program code is always composed of acombination of one alphabetic letter and a number, when a program codethat is composed of one alphabetic letter that is stored in the firststorage unit and a two-character number is recognized in a characterstring, for example, it is possible to estimate that the subsequentcharacters are any effective character stored in the second storage unitand a number having the number of digits stored in the first storageunit. Accordingly, the recognized character string can be converted soas to function as an NC program.

The above-described aspect may further include a third storage unit thatstores a number and alphabetic letters that tend to be mistaken for thisnumber, in an associated manner, wherein, when a leading character ineach segment of the character string, which is recognized by the OCRprocessing unit, is a number, the character-string segmenting unit mayreplace the number with any of the alphabetic letters stored in thethird storage unit in an associated manner.

By doing so, because there is no program code in which the leadingcharacter in each segment is a number, if the leading character is anumber, the number is replaced with an alphabetic letter stored in thethird storage unit in association with the number, thereby making itpossible to convert it so as to function as an NC program.

In the above-described aspect, when the leading character of thecharacter string, which is recognized by the OCR processing unit, is anyalphabetic letter stored in the first storage unit, the character-stringsegmenting unit may replace a character string subsequent to thisalphabetic letter with a number corresponding to the number of digitsstored in the first storage unit in an associated manner.

By doing so, it is possible to easily segment a recognized characterstring into a plurality of program codes and to convert it so as tofunction as an NC program.

In the above-described aspect, when the leading character of thecharacter string, which is recognized by the OCR processing unit, is“O”, and the number of digits of a number subsequent thereto is lessthan four digits, the character-string segmenting unit may add zerobetween the leading character and the subsequent number to replace thesubsequent number with a four-digit number.

By doing so, even in a case in which a line starting with “O” isrecognized as a program number, and the number of digits of a numbersubsequent to “O” is reduced so as to have less than four digits, zerois added before the number to replace the number with a four-digitnumber, thereby making it possible to convert it so as to function as anNC program.

In the above-described aspect, the character-string segmenting unit mayconvert a character that does not correspond to any program code, of thecharacter string, which is recognized by the OCR processing unit, into acomment sentence.

By doing so, if a character does not correspond to any program code,i.e., if a character does not correspond to any alphabetic letter storedin the first storage unit, to a number having the number of digitsstored in association with the alphabetic letter, or to any effectivecharacter stored in the second storage unit, the character that does notcorrespond to any of them is formed into a comment sentence, therebymaking it possible to perform conversion so as to function as an NCprogram.

According to the present invention, an advantageous effect is affordedin that a recognized character string can be converted so as to functionas an NC program.

1. An NC-program conversion device comprising: an OCR processing unitthat recognizes a character string from an input image; a first storageunit that stores one alphabetic letter and the number of digits of anumber subsequent to the alphabetic letter, in an associated manner; asecond storage unit that stores a program code that is composed of acombination of one alphabetic letter and a two-character number and aneffective character that is composed of one alphabetic letter subsequentto the program code, in an associated manner; and a character-stringsegmenting unit that refers to the first storage unit and the secondstorage unit, to segment each line of the character string, which isrecognized by the OCR processing unit, as program codes that are eachcomposed of one alphabetic letter and a number corresponding to thenumber of digits stored in the first storage unit in an associatedmanner.
 2. An NC-program conversion device according to claim 1, furthercomprising a third storage unit that stores a number and alphabeticletters that tend to be mistaken for this number, in an associatedmanner, wherein, when a leading character in each segment of thecharacter string, which is recognized by the OCR processing unit, is anumber, the character-string segmenting unit replaces the number withany of the alphabetic letters stored in the third storage unit in anassociated manner.
 3. An NC-program conversion device according to claim1, wherein, when the leading character of the character string, which isrecognized by the OCR processing unit, is any alphabetic letter storedin the first storage unit, the character-string segmenting unit replacesa character string subsequent to this alphabetic letter with a numbercorresponding to the number of digits stored in the first storage unitin an associated manner.
 4. An NC-program conversion device according toclaim 3, wherein, when the leading character of the character string,which is recognized by the OCR processing unit, is “O”, and the numberof digits of a number subsequent thereto is less than four digits, thecharacter-string segmenting unit adds zero between the leading characterand the subsequent number to replace the subsequent number with afour-digit number.
 5. A NC-program conversion device according to claim1, wherein the character-string segmenting unit converts a characterthat does not correspond to any program code, of the character string,which is recognized by the OCR processing unit, into a comment sentence.